home *** CD-ROM | disk | FTP | other *** search
/ The Original Shareware 1.1 / The Original Shareware (WeMake CDs)(Volume 1.1)(CDs, Inc)(1993).iso / 6 / cljune86.zip / TOUCH.C < prev    next >
Text File  |  1986-03-31  |  2KB  |  51 lines

  1. #include "stdio.h"
  2.  
  3. /******************************************************************************/
  4. /*---------------------------- The TOUCH utility -----------------------------*/
  5. /******************************************************************************/
  6. /*                                                                            */
  7. /*  Name: bump                           Version: 1.0                         */
  8. /*                                                                            */
  9. /*  Last Edit: 03/21/86                  Compiler: Lattice C, v2.15d          */
  10. /*                                                                            */
  11. /*  Purpose:  Change a file or list of files time and date stamp to the       */
  12. /*            current date and time.                                          */
  13. /*                                                                            */
  14. /******************************************************************************/
  15. /*------------------ Copyright 1985 & 1986, by Gary Elfring ------------------*/
  16. main(argc,argv)
  17.     int        argc;
  18.     char    *argv[];
  19.     {
  20.     extern    FILE    *fopen();
  21.     FILE    *ptr;
  22.     int        i;
  23.     char    buf[2];
  24.  
  25. /*---------- If only one argument, tell them how to use the program ----------*/
  26.     if (argc == 1)
  27.         {
  28.         printf("USE --> touch file1.ext file2.ext ... fileN.ext{cr}\n");
  29.         exit(1);
  30.         }
  31.  
  32. /*------------------------- For each passed argument -------------------------*/
  33.     for (i = 1; i < argc; ++i)
  34.         {
  35.         /*-------------------- Open the file for read / write --------------------*/
  36.         if ((ptr = fopen(argv[i],"rb+")) == NULL)
  37.             {
  38.             printf("Error: can not open %s\n",argv[i]);
  39.             exit(2);
  40.             }
  41.         /*---------------------------- Read in 1 byte ----------------------------*/
  42.         fread(buf,1,1,ptr);
  43.         /*-------------- Rewind the file pointer back to beginning ---------------*/
  44.         fseek(ptr,0L,0);
  45.         /*-------------- Write the byte out (force redate of file) ---------------*/
  46.         fwrite(buf,1,1,ptr);
  47.         /*----------------- Close the file and move to the next ------------------*/
  48.         fclose(ptr);
  49.         }
  50.     }